package org.peterf.foxish.math;

import android.util.FloatMath;

public class FloatUtil {

    public static float E = (float) Math.E;

    public static float PI = (float) Math.PI;

    public static float abs(float value) {
        return Math.abs(value);
    }

    public static float ceil(float value) {
        return FloatMath.ceil(value);
    }

    public static float cos(float radian) {
        return FloatMath.cos(radian);
    }

    public static float distance2(float x1, float y1, float x2, float y2) {
        float dx = (x1 - x2);
        float dy = (y1 - y2);
        return dx * dx + dy * dy;
    }

    public static float floor(float value) {
        return FloatMath.floor(value);
    }

    public static float mod(float dividend, float divisor) {
        divisor = abs(divisor);
        float quotient = (int) (dividend / divisor);
        return dividend - quotient * divisor;
    }

    public static float period(float value, float period) {
        period = abs(period);
        return value - round(value / period) * period;
    }

    public static int round(float value) {
        return Math.round(value);
    }

    public static float sin(float radian) {
        return FloatMath.sin(radian);
    }

    public static float sqrt(float value) {
        return FloatMath.sqrt(value);
    }

    public static float tan(float radian) {
        return (float) Math.tan(radian);
    }

}
